{extend name="layout:default" /}
{block name="title"}修改{/block}
{block name="content"}
<div class="box box-default">
    <div class="box-header with-border">
        <h3 class="box-title">修改活动</h3>
    </div>
    <!-- /.box-header -->
    <div class="box-body">
            <a href="{:url('index')}" class="btn btn-info">返回</a>

        <form class="form-horizontal" method="post" enctype="multipart/form-data">
            <div class="form-group">
                <label class="col-sm-2 control-label">活动名称</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" name="title" placeholder="活动名称" value="{$activity.title}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">排序</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" name="sort" placeholder="排序" value="{$activity.sort}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">活动简介</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" name="introduction" placeholder="活动简介" value="{$activity.introduction}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">限制人数</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" name="people_num" placeholder="人数" value="{$activity.people_num}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">活动详细内容</label>
                <div class="col-sm-8">
                    <textarea name="content"  cols="60" rows="5">{$activity.content}</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">是否热门</label>
                <div class="col-sm-10" >
                    <input type="radio" value="1" name="is_hot" {$activity.is_hot ===1 ? 'checked':''}>是
                    <input type="radio" value="2" name="is_hot" {$activity.is_hot ===1 ? '':'checked'}>否
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">是否最新</label>
                <div class="col-sm-10" >
                    <input type="radio" value="1" name="is_new" {$activity.is_new ===1 ? 'checked':''}>是
                    <input type="radio" value="2" name="is_new" {$activity.is_new ===1 ? '':'checked'}>否
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">是否放置主页</label>
                <div class="col-sm-10" >
                    <input type="radio" value="1" name="is_home" {$activity.is_home ===1 ? 'checked':''}>是
                    <input type="radio" value="2" name="is_home" {$activity.is_home ===1 ? '':'checked'}>否
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">状态</label>
                <div class="col-sm-10">
                    <input type="radio"  value="1" name="status" {$activity.status ===1 ? 'checked':''} >正常
                    <input type="radio"  value="2" name="status" {$activity.status ===1 ? '':'checked'}>禁用
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">所属分类</label>
                <div class="col-sm-8">
                    <select name="category_id" class="form-control">
                        {volist name="categories" id="vo"}
                        <option value="{$vo.id}" {$vo.id === $activity.category_id ? 'selected' : '' }>{$vo.name}</option>
                        {/volist}
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">所属类别</label>
                <div class="col-sm-8">
                    <select name="class_ids" class="form-control">
                        {volist name="class" id="vo"}
                        <option value="{$vo.id}" {$vo.id === $activity.class_ids ? 'selected' : '' }>{$vo.name}</option>
                        {/volist}
                    </select>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">活动开始时间</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" name="start_time" placeholder="开始时间" value="{$activity.start_time}">
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">活动结束时间</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control"  name="end_time" placeholder="结束时间" value="{$activity.end_time}">
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">课程图片</label>
                <div class="col-sm-8">
                    <img src="{$activity.thumb}" alt="" width="200">
                    <input type="file" name="image">
                </div>
            </div>

            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-4">
                    <button type="submit" class="btn btn-info pull-right">提交</button>
                </div>
            </div>
        </form>
    </div>
    <!-- /.box-body -->
</div>
{/block}

{block name="js"}
<script>
    // 图片上传demo
    jQuery(function() {
        var uploader = WebUploader.create({

            // swf文件路径
            swf: BASE_URL + '/js/Uploader.swf',

            // 文件接收服务端。
            server: 'http://webuploader.duapp.com/server/fileupload.php',

            // 选择文件的按钮。可选。
            // 内部根据当前运行是创建，可能是input元素，也可能是flash.
            pick: '#picker',

            // 不压缩image, 默认如果是jpeg，文件上传前会压缩一把再上传！
            resize: false
        });
        // 当有文件被添加进队列的时候
        uploader.on( 'fileQueued', function( file ) {
            $list.append( '<div id="' + file.id + '" class="item">' +
                '<h4 class="info">' + file.name + '</h4>' +
                '<p class="state">等待上传...</p>' +
                '</div>' );
        });
        // 文件上传过程中创建进度条实时显示。
        uploader.on( 'uploadProgress', function( file, percentage ) {
            var $li = $( '#'+file.id ),
                $percent = $li.find('.progress .progress-bar');

            // 避免重复创建
            if ( !$percent.length ) {
                $percent = $('<div class="progress progress-striped active">' +
                    '<div class="progress-bar" role="progressbar" style="width: 0%">' +
                    '</div>' +
                    '</div>').appendTo( $li ).find('.progress-bar');
            }

            $li.find('p.state').text('上传中');

            $percent.css( 'width', percentage * 100 + '%' );
        });
        uploader.on( 'uploadSuccess', function( file ) {
            $( '#'+file.id ).find('p.state').text('已上传');
        });

        uploader.on( 'uploadError', function( file ) {
            $( '#'+file.id ).find('p.state').text('上传出错');
        });

        uploader.on( 'uploadComplete', function( file ) {
            $( '#'+file.id ).find('.progress').fadeOut();
        });
    });
</script>
{/block}